package com.sc.smartcommunity.controller;

import com.sc.smartcommunity.domain.OwnerComplaint;
import com.sc.smartcommunity.service.OwnerComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/complaint")
public class OwnerComplaintController {

    @Autowired
    private OwnerComplaintService ownerComplaintService;

    @PostMapping("/submit")
    public String submitComplaint(@RequestBody OwnerComplaint complaint) {
        boolean result = ownerComplaintService.saveComplaint(complaint);
        if (result) {
            return "投诉提交成功";
        } else {
            return "投诉提交失败";
        }
    }
    @GetMapping("/owner/{phoneNumber}")
    public List<OwnerComplaint> getComplaintsByOwnerId(@PathVariable String phoneNumber) {
        return ownerComplaintService.getComplaintsByOwnerphone(phoneNumber);
    }
}